/**
 * Author:   anTi
 * Date:     2018/11/24 12:47
 * Description:
 * version: 1.0
 */

package com.imooc.avtiviti.event;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ProcessEventListener implements ActivitiEventListener {
    private static final  Logger LOGGER= LoggerFactory.getLogger(ProcessEventListener.class);
    @Override
    public void onEvent(ActivitiEvent activitiEvent) {
        //流程开始打印日志
        //流程结束打印日志
        ActivitiEventType type = activitiEvent.getType();
        if (ActivitiEventType.PROCESS_STARTED.equals(type)){
            LOGGER.info("流程启动 {} \t {}",type,activitiEvent.getProcessInstanceId());
        }else if (ActivitiEventType.PROCESS_COMPLETED.equals(type)){
            LOGGER.info("流程结束 {} \t {}",type,activitiEvent.getProcessInstanceId());
        }
    }

    @Override
    public boolean isFailOnException() {
        return false;
    }

}
